using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace DungeonOfDespair
{
    public class Spells
        : List<Spell>
    {
        Room m_room;

        public Spells(Room room)
        {
            m_room = room;
        }

        public void Reset()
        {
            this.Clear();
        }

        public void Update()
        {
            for (int iIndex = this.Count - 1; iIndex >= 0; iIndex--)
            {
                Spell spell = this[iIndex];
                spell.Update();
                if (!spell.Active)
                {
                    Image imageEffect = spell.Friendly
                        ? Properties.Resources.PlayerSpellBlast
                        : Properties.Resources.EnemySpellBlast;
                    Effect effect = new Effect(m_room.Effects, imageEffect, 10);
                    effect.X = spell.X;
                    effect.Y = spell.Y;
                    m_room.Effects.Add(effect);
                    this.RemoveAt(iIndex);
                }
            }
        }

        public void Draw(Graphics graphics)
        {
            foreach (Spell spell in this)
                spell.Draw(graphics);
        }

        public Room Room
        {
            get { return m_room; }
        }
    }
}
